From 6838bf3e06a0a29d08f6f6d362f0d2dbe7366aed Mon Sep 17 00:00:00 2001 From: Wil Mahan Date: Mon, 11 Oct 2004 16:16:27 +0000 Subject: [PATCH] Prevent double-escaping of '<' and '>' in external links; allow them in free external links again, at least until there is a consistent way of handling them. Convert some spaces to tabs from zhengzhu's last commit. --- includes/Parser.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index 4b79b83e25..82377a5143 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -38,7 +38,7 @@ define( 'UNIQ_PREFIX', 'NaodW29'); define( 'URL_PROTOCOLS', 'http|https|ftp|irc|gopher|news|mailto' ); define( 'HTTP_PROTOCOLS', 'http|https' ); # Everything except bracket, space, or control characters -define( 'EXT_LINK_URL_CLASS', '[^]<>\\x00-\\x20\\x7F]' ); +define( 'EXT_LINK_URL_CLASS', '[^]\\x00-\\x20\\x7F]' ); # Including space define( 'EXT_LINK_TEXT_CLASS', '[^\]\\x00-\\x1F\\x7F]' ); define( 'EXT_IMAGE_FNAME_CLASS', '[A-Za-z0-9_.,~%\\-+&;#*?!=()@\\x80-\\xFF]' ); @@ -655,7 +655,7 @@ class Parser * @access private */ function internalParse( $text, $linestart, $args = array(), $isMain=true ) { - global $wgContLang; + global $wgContLang; $fname = 'Parser::internalParse'; wfProfileIn( $fname ); @@ -1026,8 +1026,11 @@ class Parser $url = substr( $url, 0, -$numSepChars ); } - # Replace & from obsolete syntax with & - $url = str_replace( '&', '&', $url ); + # Replace & from obsolete syntax with &; + # undo escaping of '<' and '>' by removeHTMLtags(), + # to prevent double-escaping. All HTML entities will + # be escaped by makeExternalLink() or maybeMakeImageLink() + $url = str_replace( array('&', '<', '>'), array('&', '<', '>'), $url ); # Is this an external image? $text = $this->maybeMakeImageLink( $url ); @@ -1291,7 +1294,7 @@ class Parser } } - $text = $wgContLang->convert($text); + $text = $wgContLang->convert($text); if( ( $nt->getPrefixedText() === $this->mTitle->getPrefixedText() ) && ( strpos( $link, '#' ) === FALSE ) ) { -- 2.20.1